#ifndef ISOLATION_CALCULATOR_H
#define ISOLATION_CALCULATOR_H

#include "PeriodicBoundary.h"
#include "FieldCircuitCoupling.h"
#include <vector>

namespace FieldCircuitCoupling {

class MoMFieldSolver;

// Isolation calculator class, responsible for handling all isolation-related calculations
class IsolationCalculator {
public:
    IsolationCalculator(MoMFieldSolver* solver);
    ~IsolationCalculator();
    
    // Compute isolation matrix
    bool computeIsolationMatrix(const std::vector<CouplingPort>& ports, 
                              std::vector<std::vector<Complex>>& isolationMatrix);
    
    // Compute S-parameters matrix
    bool computeSParameters(const std::vector<CouplingPort>& ports, 
                            std::vector<std::vector<Complex>>& sMatrix);
    
    // Convert isolation to decibels
    double computeIsolationInDB(const Complex& isolation);
    
    // Compute isolation between two specific ports
    bool computePortIsolation(const CouplingPort& sourcePort, const CouplingPort& observePort, Complex& isolation);
    
    // Directly compute isolation between two specific ports in dB
    bool computePortIsolationInDB(const CouplingPort& sourcePort, const CouplingPort& observePort, double& isolationDB);
    
    // Compute port reflection coefficient
    bool computePortReflection(const CouplingPort& port, Complex& reflectionCoeff);
    
    // Compute impedance distribution of port
    bool computePortImpedance(const CouplingPort& port, std::vector<Complex>& impedanceVector);
    
    // Compute distance between two points
    double computeDistance(const Vector_3D& point1, const Vector_3D& point2);
    
    // Compute angle between two vectors
    double computeAngle(const Vector_3D& vec1, const Vector_3D& vec2);
    
private:
    MoMFieldSolver* solver;  // Pointer to MoMFieldSolver for accessing necessary member variables and methods
};

extern "C" {
    __declspec(dllexport) void* CreateIsolationCalculatorManager();
}
} // namespace FieldCircuitCoupling

#endif // ISOLATION_CALCULATOR_H